﻿using MiscHelper;
using NUnit.Framework;

namespace MiscHelperTest
{
    public class EmailFieldParserUT
    {
        [Test]
        public void NullField()
        {
            var l = EmailFieldParser.Parse(null);
            Assert.AreEqual(0, l.Count);
        }

        [Test]
        public void EmptyField()
        {
            var l = EmailFieldParser.Parse("");
            Assert.AreEqual(0, l.Count);
        }

        [Test]
        public void EmptySpaceField()
        {
            var l = EmailFieldParser.Parse(" ");
            Assert.AreEqual(0, l.Count);
        }

        [Test]
        public void SemiColonSeparator()
        {
            var l = EmailFieldParser.Parse("xbtrvlmk@laotel.com;vill_muong_khong@126.com");
            Assert.AreEqual(2, l.Count);
        }

        [Test]
        public void CommaSeparator()
        {
            var l = EmailFieldParser.Parse("info@kiridara.com , gm@kiridara.com");
            Assert.AreEqual(2, l.Count);
            Assert.AreEqual("info@kiridara.com", l[0]);
            Assert.AreEqual("gm@kiridara.com", l[1]);
        }

        [Test]
        public void ForwardSlashSeparator()
        {
            var l = EmailFieldParser.Parse("sales@donchanpalacelaopdr.com/resvervation@donchanpalacelaopdr.com");
            Assert.AreEqual(2, l.Count);
        }

        [Test]
        public void InvalidEmail()
        {
            var l = EmailFieldParser.Parse("nickatanotherurl.com");
            Assert.AreEqual(0, l.Count);
        }

        [Test]
        public void NullStringThatActuallyHasNull()
        {
            var l = EmailFieldParser.Parse("NULL");
            Assert.AreEqual(0, l.Count);
        }

        [Test]
        public void MakeLowerCase()
        {
            var l = EmailFieldParser.Parse("nick@Anotherurl.coM");
            Assert.AreEqual(1, l.Count);
            Assert.AreEqual("nick@anotherurl.com", l[0]);
        }
    }
}
